<%@ page isELIgnored="false" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
	<title>主页</title>
	<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css"/>
	<script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header" >
			<div class="layui-logo">教务管理系统</div>
			<ul class="layui-nav layui-layout-left">   </ul>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item">
				    <a href="javascript:;">
				        	<img width="40px" height="30px" src="/pic/${user.image}" /> ${user.name}
				    </a>
					<dl class="layui-nav-child">
						<dd>
							<a href="javascript:openUser()" >基本资料</a>
						</dd>
						<dd>
							<a href="javascript:openPass()">修改密码</a>
						</dd>
						<dd>
                            <a href="javascript:openPic()">修改头像</a>
                        </dd>
					</dl>
				</li>
				<li class="layui-nav-item">
				    <a href="javascript:logout()">注销</a>
				</li>
			</ul>
		</div>
		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree" >
					<li class="layui-nav-item layui-nav-itemed">
					    <a href="javascript:;">教务管理系统</a>
						<dl class="layui-nav-child">

							<c:forEach items="${auths}" var="auth">
								<dd>
									<a href="javascript:;"
									   data-url="${auth.path}"
									   class="site-demo-active">${auth.name}</a>
								</dd>
							</c:forEach>

						</dl>
					</li>

				</ul>
			</div>
		</div>
		<div class="layui-body"><!-- 内容主体区域 -->
			<iframe name="rightframe" width="99%" height="97%" src="/page/echarts"></iframe>
		</div>
		<div class="layui-footer">© JAVA - 底部固定区域</div>
	</div>
	<script type="text/javascript">
		var $ = layui.jquery;
		var layer = layui.layer;
		var element = layui.element;
        $('.site-demo-active').click(function() {
            window.open($(this).data('url'), "rightframe");
        });


		element.render();
		// element.init();

		function openURL(url){

			window.open(url, "rightframe");
		}



		function openUser() {

			//卫语句
			if (${user.role} == 1){
				layer.open({
					type:2,
					title:'学院管理员基本信息',
					area:['50%','50%'],// 宽高
					content:'/page/openXi/update?id=' + ${user.id}
				});
			}

			if (${user.role} == 2){
				layer.open({
					type:2,
					title:'教师基本信息',
					area:['50%','50%'],// 宽高
					content:'/page/openTeacher/update?id=' + ${user.id}
				});
			}

			if (${user.role} == 3){
				layer.open({
					type:2,
					title:'学生基本信息',
					area:['50%','50%'],// 宽高
					content:'/page/openUser/update?id=' + ${user.id}
				});
			}
		}

		function openPass() {
			layer.open({
				type:2,
				title:'修改密码',
				area:['50%','50%'],// 宽高
				content:'/page/openPass/update?id=' + ${user.id}
			});
		}

		function openPic() {
			layer.open({
				type:2,
				title:'上传图片',
				area:['50%','50%'],// 宽高
				content:'/page/openPic/update?id=' + ${user.id}
			});
		}

		function logout() {
			layer.confirm('您确认要删除吗?',{icon:3},function () {
				$.post(
					'/user?method=logout',
					function (result) {
						if (result.code == 0){
							location.href = '/';
						}
					},
					'json'
				);
			});
		}

	</script>
</body>
</html>